package demo10.iterator.dinermergercafe;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

/**
 * 新添加的咖啡厅菜单
 * */
public class CafeMenu implements Menu{
		//采用hashmap集合
	HashMap<String, MenuItem> menuItems = new HashMap<String, MenuItem>();
	  
	public CafeMenu() {
		addItem("素食汉堡和炸薯条","全麦面包，生菜，西红柿和薯条上的蔬菜汉堡",true, 3.99);
		addItem("例汤","一杯当天的汤，配一份沙拉",false, 3.69);
		addItem("玉米煎饼","一个大煎饼，全豆，莎莎，鳄梨酱",true, 4.29);
	}
 //构造器 
	public void addItem(String name, String description, 
	                     boolean vegetarian, double price) 
	{
		MenuItem menuItem = new MenuItem(name, description, vegetarian, price);
		//key 为name 值 为map
		menuItems.put(menuItem.getName(), menuItem);
	}
 
	public Map<String, MenuItem> getItems() {
		return menuItems;
	}
     //迭代获取key
	@Override
	public Iterator<MenuItem> createIterator() {
		return menuItems.values().iterator();
	}
}
